/** 
 * DefaultDebutsParser.java Created by iweerarathna on Aug 30, 2011.
 * 
 * Copyright (c) 2011 Virtusa Corporation. All Rights Reserved.<br><br>. 
 * 
 */
package org.uim.cricket.analyzer.parsers.match.impl;

import java.util.ArrayList;

import org.uim.cricket.analyzer.parsers.match.DebutsParsable;
import org.uim.cricket.entities.Player;
import org.uim.cricket.util.HTMLStringUtils;
import org.uim.cricket.util.MyStringUtils;;

/**
 * TODO Class description goes here.
 * @version 
 * @author iweerarathna
 */
public class DefaultDebutsParser implements DebutsParsable {

    @Override
    public Player[] parseDebutants(StringBuilder sb) {
        if (sb == null || sb.length() == 0) return null;
        ArrayList<Player> debuts = new ArrayList<Player>();
        
        String[] dps = MyStringUtils.splitInBetween(sb.toString(), "<span", "</span>");
        for (int i=0;i<dps.length;i++) {
            debuts.add(new Player(HTMLStringUtils.cleanHTMLTags("<span" + dps[i]).trim()));
        }
        
        Player[] results = new Player[debuts.size()];
        debuts.toArray(results);
        return results;
    }

}
